<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>swagger2html</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
	function upload() {
		if($('#jsonFile')[0].files.length==0){
			return;
		}
		var form = new FormData();
		form.append('file', $('#jsonFile')[0].files[0]);
		form.append('type', 'file');
		jQuery.ajax({
			url: 'https://api.xlongwei.com/service/upload',
			type: 'POST',
			data: form,
			processData: false,
			contentType: false,
			success: function(res) {
				console.log(res)
				var url = res.url || res.domain + res.path;
				if(url && url.endsWith('.json')) {
					url = 'https://api.xlongwei.com/swagger/doc.html?jsonUrl=' + url.replace('http://s.','https://t.');
					console.log(url)
					$('#swagger2md').attr('href', url).show();
				}
			}
		});
	}
</script>
</head>
<body>
	<div class="container">
		<form enctype="multipart/form-data" method="post">
			<div class="form-group row">
				<label for="jsonUrl" class="col-sm-2 col-form-label"><a href="http://cms.xlongwei.com/demo/upload.html" title="upload" target="_blank">jsonUrl</a></label>
				<div class="col-sm-10">
					<input name="jsonUrl" id="jsonUrl" class="form-control" placeholder="优先使用jsonUrl，可选上传jsonFile">
				</div>
			</div>
			<div class="form-group row">
				<label for="jsonFile" class="col-sm-2 col-form-label">jsonFile</label>
				<div class="col-sm-7">
					<input name="jsonFile" id="jsonFile" type="file"
						class="form-control-file">
				</div>
				<div class="col-sm-3">
					<button type="button" onclick="upload()" class="btn btn-primary">Upload</button>
					<a id="swagger2md" class="form-control-inline" style="display:none">swagger2md</a>
				</div>
			</div>
			<div class="form-group row">
				<label for="tags" class="col-sm-2 col-form-label">tags</label>
				<div class="col-sm-10">
					<input name="tags" id="tags" class="form-control" placeholder="逗号分隔用于过滤，分组名通常是全类名转小写带减号，类似query-report-controller">
				</div>
			</div>
			<button type="submit" class="btn btn-primary">Submit</button>
		</form>
	</div>
</body>
</html>